<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let Arr = [1, 2, 4, 4, 3, 5]
    function findNum(arr, k) {

      arr.sort((a, b) => b - a)

      // 从去重的数组中取出大小目标值
      let setArr = [...new Set(arr)]
      let target = setArr[k - 1]

      console.log(target);
      if (!target) return []

      // 看是否有多个值
      const key = arr.indexOf(target)
      const lastKey = arr.lastIndexOf(target)
      console.log(key, lastKey);

      if (key === lastKey) return [target]
      else return arr.slice(key, lastKey + 1)


    }
    console.log(findNum(Arr, 6));




  </script>
</body>

</html>